package inutan.game.task;

import inutan.game.condition.Condition;

import java.util.Collection;

public interface CompositeCondition <T extends Condition, E> extends Condition<E> {

    enum CompleteType {
        ANY, //任务组任务一个完成即完成任务
        ALL //全部完成才算完成
    }

    default CompleteType completeType() {
        return CompleteType.ALL;
    }

    Collection<T> conditions();

    @Override
    default void emit(E e) {

    }

    @Override
    default boolean isDone(E e) {
        return completeType() == CompleteType.ALL
                ? conditions().stream().allMatch(conditions -> conditions.isDone(e))
                : conditions().stream().anyMatch(conditions -> conditions.isDone(e));
    }
}
